using System;
using System.Threading;
using System.Web.UI;
using SouthernLand.Common;

namespace SouthernLand.WebMaster.Controls.Contacts
{
    public partial class ContactDetail : UserControl
    {
        private int ContactID;

        protected void Page_Load(object sender, EventArgs e)
        {
            ContactID = Convert.ToInt32(Request.QueryString["ContactID"]);
            if (!Page.IsPostBack)
            {
                Common.BOL.Contact.Contact obj = Common.BOL.Contact.Contact.GetContactByID(ContactID);
                lblFullName.Text = obj.FullName;
                lblAddress.Text = obj.Address;
                lblTel.Text = obj.Tel;
                lblEmail.Text = obj.Email;
                lblPostDate.Text = obj.AddedDate.ToString();
                lblTitle.Text = obj.Title;
                lblContent.Text = obj.Content;
            }

            btDelete.OnClientClick = "if (confirm('Are you sure you want to delete this post?') == false) return false;";
        }

        protected void btDelete_Click(object sender, EventArgs e)
        {
            Common.BOL.Contact.Contact.Delete(ContactID);
            Response.Redirect(Globals.ApplicationPath + "WebMaster/Contacts/Contact.aspx");
        }
    }
}